home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 2534 / text0000.txt < prev   
Encoding:
Text File  |  1996-08-05  |  684 b   |  23 lines

  1. In a message of 30 Jan 96 Tony Syslo wrote to All:
  2.  
  3.  TS>   char name[80];
  4. [...]
  5.  TS>    name="";
  6.  
  7. It doesn't work quite like this in C.. "" is a pointer to an empty
  8. null-terminated string (ie, a pointer to a 0-byte). The statement above is
  9. trying to set the address of the first byte of your char array to point to this
  10. string. It's not how you clear a string (any my compiler refuses to compile
  11. this line!).
  12.  
  13. To empty your string, try:
  14.  
  15.   name[0] = 0;  
  16.  
  17. That'll set the first byte of the string to be a character 0. This is the
  18. string termination byte and so it effectively means the string is now
  19. 0-length/empty.
  20.  
  21. .\dam.          [Team AMIGA]          //\ ad32@brighton.ac.uk \\/
  22.  
  23.